<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link href="../../Content/CSS/mojie/mui.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../Content/CSS/mojie/demo.css"/>
		<link rel="stylesheet" href="../../Content/CSS/mojie/iconfont.css"/>
		<link rel="stylesheet" href="../../Content/CSS/mojie/icons-extra.css" />
		<link rel="stylesheet" href="../../Content/CSS/mojie/style.css" />
		<script src="../../data/goods.js"></script>
	</head>

	<body>
		<!--下拉刷新容器-->
		<div id="pullrefresh" class="mui-content mui-scroll-wrapper">
			<div class="mui-scroll">
				<!--数据列表-->
				<ul id="goods-list" class="item bg">
					
				</ul>
			</div>
		</div> 
		<script src="../../Content/JS/mojie/mui.min.js"></script>
		<script src="../../Content/JS/mojie/mojie.js"></script>
		<script>
		document.getElementsByClassName()
			mui.init();
			mui.init({
				pullRefresh: {
					container: '#pullrefresh',
//					down: {
//						callback: pulldownRefresh
//					},
					up: {
						contentrefresh: '正在加载...',
						callback: pullupRefresh
					}
				}
			});
			
			
			/**
			 * 下拉刷新具体业务实现
			 */
			function pulldownRefresh() {
				setTimeout(function() {
					var teamCode = getQueryString('teamCode');
					var search = getQueryString('search');
					var BrandName = getQueryString('BrandName');
					var ProductGroup = getQueryString('ProductGroup');
					var ProductType = getQueryString('ProductType');
					var intSortField = getQueryString('intSortField');
					var strSortOrder = getQueryString('strSortOrder');
					$.ajax({
						type: "POST",
					    url: "../MobileMall/teamproductajax?teamCode=" + teamCode + "&search=" + search + "&BrandName=" + BrandName + "&ProductGroup=" + ProductGroup + "&ProductType=" + ProductType + "&intSortField=" + intSortField + "&strSortOrder=" + strSortOrder,
					    cache: false,
					    success: function(html){
					    	var table = document.body.querySelector('.item');
							var cells = document.body.querySelectorAll('.goods-list-cell');
						}
					});
				}, 1500);
			}
			var count = 0;
			/**
			 * 上拉加载具体业务实现
			 */
			function pullupRefresh() {
				setTimeout(function() {
					mui('#pullrefresh').pullRefresh().endPullupToRefresh((++count > 2)); //参数为true代表没有更多数据了。
					var table = document.body.querySelector('.item');
					var cells = document.body.querySelectorAll('.goods-list-cell');
					mui.each(goods,function(key,value){
						var li = document.createElement('li');
						li.className = 'goods-list-cell';
						li.innerHTML += '<a href="orderdetail.html?'+ value.pid +'">';
						li.innerHTML += '<figure><img src="' + value.pic + '"/></figure>';
						li.innerHTML += '<span class="mall-color-title mall-white">' + value.name +'</span>';
						li.innerHTML += '<section><span class="mall-font-14 mall-color-btn">￥' + value.price + '</span>';
						li.innerHTML += '<span class="fr mall-color-def">' + value.fukuan + '人付款</span></section></a>';
						li.innerHTML += '<a class="addshopcart">加入购物车</a>';
						table.appendChild(li);
					})	
				},1500)
			}
			if (mui.os.plus) {
				mui.plusReady(function() {
					setTimeout(function() {
						mui('#pullrefresh').pullRefresh().pullupLoading();
					}, 1000);

				});
			} else {
				mui.ready(function() {
					mui('#pullrefresh').pullRefresh().pullupLoading();
				});
			}
			//实现a链接跳转
			mui('#goods-list').on( 'tap' , 'a' , function(){
			//业务逻辑
			var urlselect = this.getAttribute("href");
			mui.openWindow({
			    url: urlselect
			  });
			} );
			
			mui(".addshopcart").on('tap',function(){
				
				var jsonData = {
		            productToken: $(this).getAttribute('productToken'),
		            attributId: $(this).getAttribute('AttributeId'),
		            num: "1"
		        };
		        mui.ajax('',)
			})
			AddCar.addEventListener('tap',function(productToken, formatId){
				var jsonData = {
		            productToken: productToken,
		            attributId: formatId,
		            num: "1"
		        };
		        $.ajax({
	            	type: "POST",
		            url: "../MobileMall/AddShooppingCar".getJumpUrl(),
		            data: jsonData,
		            dataType: 'json',
		            success: function (result) {
		                if (result.messagecode == 5) {
		                        MobileAlert("添加购物车成功，您可继续浏览", 500);
		                }
		            },
		            error: function (XMLHttpRequest, textStatus, errorThrown) {
		            }
        		});
    		}
			})
		</script>
	</body>

</html>